package com.ckerchina.admin.ckadmin.service.sms.providerImpl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.ckerchina.admin.ckadmin.service.sms.SMSServiceProvider;
import com.ckerchina.admin.ckadmin.service.sms.dto.SmsReceiveReport;
import com.ckerchina.admin.ckadmin.service.sms.dto.SmsSendResult;
import com.ckerchina.admin.ckadmin.service.sms.dto.SmsStatusReport;
import com.ckerchina.admin.ckadmin.service.sms.util.ProgroupSmsUtil;

@Component
public class ProgroupSmsProvider implements SMSServiceProvider {

	private String URL = "http://115.29.196.232:8888";
	private String userName = "10690-rrz";
	private String password = "690rrz";
	private String userid = "129";
	@Value(value = "${progroupVMS.userName}")
	private String VMSuserName;
	@Value(value = "${progroupVMS.password}")
	private String VMSpassword;
	@Value(value = "${progroupVMS.userid}")
	private String VMSuserid;
	@Value(value = "${progroupVMS.callerNumber}")
	private String VMScallerNumber;

	public SmsSendResult sendMessage(String mobiles, String content) {
		return ProgroupSmsUtil.sendMessage(mobiles, content, URL, userName, password, userid);
	}

	public SmsSendResult sendMessage(String[] mobileArray, String content) {
		String mobiles = StringUtils.join(mobileArray, ",");
		return this.sendMessage(mobiles, content);
	}

	public Integer queryBalance() {
		return ProgroupSmsUtil.queryBalance(URL, userName, password, userid);
	}

	public List<SmsStatusReport> queryStatusReport() {
		return ProgroupSmsUtil.queryStatusReport(URL, userName, password, userid);
	}

	public List<SmsReceiveReport> receiveMessage() {
		return ProgroupSmsUtil.receiveMessage(URL, userName, password, userid);
	}

	public SmsSendResult sendVMS(String mobiles, String code) {
		return ProgroupSmsUtil.sendVMS(mobiles, code, VMScallerNumber, URL, VMSuserName, VMSpassword, VMSuserid);
	}

	public List<SmsStatusReport> queryVMSStatusReport() {
		return ProgroupSmsUtil.queryVMSStatusReport(URL, VMSuserName, VMSpassword, VMSuserid);
	}
}
